package apiday04home;

import java.util.ArrayList;
import java.util.List;

public class ListHome {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        String a = list.get(2);//获取下标2所对应的元素
        System.out.println(a);

        list.set(1, "dada");//将下标为1的元素设置为dada
        System.out.println(list);

        list.remove(2);//删除下标为2的元素
        System.out.println(list);

        list.add(1, "aaaa");//在list下标为1的位置插入aaaa
        System.out.println(list);

        List<String> sublist = list.subList(1, 2);//获取下标1到2的子集
        System.out.println(sublist);
    }
}
